package com.smalls.newvideotwo.view;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.smalls.newvideotwo.utils.MeasureUtil;

/**
 * Created by hs on 2018/3/15.
 */

public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
    private int space;
    public SpacesItemDecoration(int space) {
        this.space = space;
    }
    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        //outRect.left = (int)MeasureUtil.getWidthSize(space);
        //outRect.right = (int) MeasureUtil.getWidthSize(space);
        //outRect.bottom = (int) MeasureUtil.getHeightSize(space);
        // Add top margin only for the first item to avoid double space between items
        int pos = parent.getChildPosition(view);
        if (parent.getChildCount()>1&&pos != 0) {
            outRect.left = (int)MeasureUtil.getWidthSize(space);
        }
    }
}
